package com.codingman.jpademo4;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.TypedQuery;

public class Demo1 {
	public static void main(String[] args) {
		EntityManagerFactory emf = Persistence.createEntityManagerFactory("employee_unit");
		EntityManager em = emf.createEntityManager();

		em.getTransaction().begin();
		
		TypedQuery<Employee> query = em.createQuery("Select e from Employee e", Employee.class);  
		List<Employee> list = query.getResultList();
		for(Employee s:list) {
			System.out.println(s);
		}

		em.getTransaction().commit();

		em.close();
		emf.close();
	}
}
